]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
app: Work around pkexec restriction when launching
authorFlorian Müllner <fmuellner@gnome.org>
Sat, 25 Mar 2017 01:46:25 +0000 (02:46 +0100)
committerFlorian Müllner <fmuellner@gnome.org>
Tue, 12 Sep 2017 15:32:51 +0000 (17:32 +0200)
Unless automatic child reaping is disabled in GSpawnFlags, glib's
g_spawn_* functions will reparent the spawned process to init by
double-forking. Unfortunately pkexec bails out in this case[0],
which means that it no longer works in .desktop files since the
PID tracking removal in commit 01c6392c1373.
Fix this by going back to manual child reaping.

[0] https://cgit.freedesktop.org/polkit/tree/src/programs/pkexec.c#n728

https://bugzilla.gnome.org/show_bug.cgi?id=763531

src/shell-app.c

index b383d9ca539d1a37fadc16a03945699398c22ad3..335147c19e38ef28c43de8f35c76aff028bfa4ef 100644 (file)
@@ -1196,6 +1196,14 @@ app_child_setup (gpointer user_data)
 }
 #endif
 
+static void
+wait_pid (GDesktopAppInfo *appinfo,
+          GPid             pid,
+          gpointer         user_data)
+{
+  g_child_watch_add (pid, (GChildWatchFunc) g_spawn_close_pid, NULL);
+}
+
 /**
  * shell_app_launch:
  * @timestamp: Event timestamp, or 0 for current event timestamp
@@ -1234,13 +1242,13 @@ shell_app_launch (ShellApp     *app,
 
   ret = g_desktop_app_info_launch_uris_as_manager (app->info, NULL,
                                                    context,
-                                                   G_SPAWN_SEARCH_PATH,
+                                                   G_SPAWN_SEARCH_PATH | G_SPAWN_DO_NOT_REAP_CHILD,
 #ifdef HAVE_SYSTEMD
                                                    app_child_setup, (gpointer)shell_app_get_id (app),
 #else
                                                    NULL, NULL,
 #endif
-                                                   NULL, NULL,
+                                                   wait_pid, NULL,
                                                    error);
   g_object_unref (context);